package com.woniu.ucenterservice.web;


import com.woniu.commom.returnvalue.RestResult;
import com.woniu.ucenterservice.service.EmailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import static com.woniu.ucenterservice.utils.VerCodeGenerateUtil.generateVerCode;


/**
 * @author: Kellen-PC
 * @date: 2019/5/5
 * @description:
 */
@RestController
public class EmailController {
    @Autowired
    EmailService emailService;
    @PostMapping("/email")
    public RestResult sendEmail(@RequestParam("emailAddress") String emailAddress) {
        try {
            emailService.sendEmailVerCode(emailAddress,generateVerCode());
            System.out.println(1);
            return RestResult.success("邮件发送成功");
        } catch (Exception e) {
            System.out.println(e);
            return RestResult.failed("邮件发送失败");
        }
    }
}

